p = Sys.getenv('PATH')
p = paste(p, 'c:\\Program Files\\Mono-3.0.9\\bin', sep=';')
Sys.setenv(PATH=p)
#
Sys.setenv(RCLR='Mono')
Sys.setenv(RCLR_DEBUG=1)

library(testthat)
library(rClr)
# test_package('rClr')
#clrInit(TRUE)
# clrInit()
cTypename <- "Rclr.TestCases"
testClassName <- "Rclr.TestObject";
obj <- clrNew(testClassName)
clrReflect(obj) 

clrGetStaticMembers(obj_or_typename='Rclr.ClrFacade')
clrGetStaticMembers(obj_or_typename='Rclr.ClrFacade')
clrGetStaticMembers(obj_or_typename='Rclr.ClrFacade')

clrGetStaticProperties(obj_or_typename='Rclr.ClrFacade')
clrGetStaticProperties(obj_or_typename='Rclr.ClrFacade')
clrGetStaticProperties(obj_or_typename='Rclr.ClrFacade')



for (i in 1:10) {
  print(clrGetStaticProperties('Rclr.ClrFacade'))
}

clrCallStatic(cTypename, "CreateNumArray")
clrCallStatic(cTypename, "CreateFloatArray")
clrCallStatic(cTypename, "NumArrayEquals", expectedNumArray )


testDateStr='2001-01-01'; numDays = 5;

extptr <-.External("r_call_static_method", cTypename, "CreateTestObject",PACKAGE=clrGetNativeLibName())
expect_that(is.null(extptr), is_false())
expect_that("externalptr" %in% class(extptr), is_true())
clrTypeNameExtPtr(extptr)

expect_that(clrTypeNameExtPtr(extptr), equals(testClassName))




testDateStr='2001-01-01'
expect_that( clrCallStatic(cTypename, "DateEquals", as.Date(testDateStr), testDateStr), is_true() );
clrDate <- clrCallStatic(cTypename, "CreateDate", testDateStr)
expect_that( clrDate, equals(as.Date(testDateStr)) );
expect_that( class(clrDate), equals('Date') );

# Check  that http://r2clr.codeplex.com/workitem/37 has been fixed
x <- as.Date(testDateStr)
clrType = clrCallStatic('Rclr.ClrFacade', 'GetObjectTypeName', x)
expect_that( x, equals(as.Date(testDateStr)) );

